{% extends "base/base.html" %}
{% load i18n %}

{% block title %}{% trans "Registro" %}{% endblock %}
{% comment %} Register Company or Candidate {% endcomment %}
{% block page-header %}{{ pageheader }}{% endblock %}

{% block content %}
    <form enctype="multipart/form-data" action="." method="post">
        {% csrf_token %}
        {% if form_user.errors %}
            {{ form_user.errors }}
        {% endif %}
        {% if form_address.errors %}
            {{ form_address.errors }}
        {% endif %}
        {% if form_company.errors %}
            {{ form_company.errors }}
        {% endif %}
    <img src="/static/{{ logo }}" alt="logo" height="150" width="150">
    {% if registration %}
        <p><label for="id_username">{% trans "Nombre de Usuario" %}:</label>
            {{ form_user.username }}
        </p>
        <p><label for="id_email">{% trans "E-mail" %}:</label>
            {{ form_user.email }}
        </p>
        <p><label for="id_email_repeat">{% trans "Confirmar E-mail" %}:</label>
            {{ form_user.email_repeat }}
        </p>
        <p><label for="id_password">{% trans "Contraseña" %}:</label>
            {{ form_user.password }}
        </p>
        <p><label for="id_password_repeat">{% trans "Confirmar Contraseña" %}:</label>
            {{ form_user.password_repeat }}
        </p>
    {% endif %}
        <p><label for="id_first_name">{% trans "Nombre" %}:</label>
            {{ form_user.first_name }}
        </p>
        <p><label for="id_last_name">{% trans "Apellidos" %}:</label>
            {{ form_user.last_name }}
        </p>
        <p><label for="id_country">{% trans "País" %}:</label>
            {{ form_address.country }}
        </p>
        <p><label for="id_state">{% trans "Estado" %}:</label>
            {{ form_address.state }}
        </p>
        <p><label for="id_municipal">{% trans "Municipio" %}:</label>
            {{ form_address.municipal }}
        </p>
        <p><label for="id_street">{% trans "Calle" %}:</label>
            {{ form_address.street }}
        </p>
        <p><label for="id_postal_code">{% trans "Codigo Postal" %}:</label>
            {{ form_address.postal_code }}
        </p>
        <p><label for="id_city">{% trans "Ciudad" %}:</label>
            {{ form_address.city }}
        </p>
        <p><label for="id_company_name">{% trans "Nombre de su Empresa" %}:</label>
            {{ form_company.company_name }}
        </p>
        {# TODO Especificar formato XXX-XXX-XXXX #}
        <p><label for="id_company_phone">{% trans "Teléfono" %}:</label>
            {{ form_company.company_phone }}
        </p>
        <p><label for="id_company_area">{% trans "Sector" %}:</label>
            {{ form_company.company_area }}
        </p>
        <p><label for="id_company_industry">{% trans "Giro" %}:</label>
            {{ form_company.company_industry }}
        </p>
        <p><label for="id_url">{% trans "Página Web" %}:</label>
            {{ form_company.url }}
        </p>
        <p><label for="id_logo">{% trans "Logo" %}:</label>
            {{ form_company.logo }}
        </p>
        <fieldset class="submit-row">
            <p>
                <button type="submit">
                    {% if registration %}
                        {% trans "Crear Cuenta" %}
                    {% else %}
                        {% trans "Modificar Perfil" %}
                    {% endif %}
                </button>
            </p>
        </fieldset>

    </form>

{% endblock %}

{% block java_script %}
{#    {% include "state_js.html" %}#}
    <script type="text/javascript">
        $(document).ready(function () {
{#            var x=document.getElementById("id_state");#}
{#            alert(x.value);#}
{#            var div_municipal = document.getElementById("div_municipal");#}
{#            if (document.getElementById("id_municipal").value == 0) {#}
{#                $('#div_municipal').removeClass("visible").addClass("invisible");#}
{#            } else {#}
{#                $('#div_municipal').removeClass("invisible").addClass("visible");#}
{##}
{#            };#}
{#            Dajaxice.companies.get_states(Dajax.process, {'option': x.value});#}
            $(function() {
                $('#id_country').change(
                    function() {
                        Dajaxice.companies.get_states(Dajax.process, {'option':this.value});
                        Dajaxice.companies.get_municipals(Dajax.process, {'option':0});
                    }
                );
                $('#id_state').change(
                    function() {
                        Dajaxice.companies.get_municipals(Dajax.process, {'option':this.value});
                    }
                );
                $('#id_company_area').change(
                    function() {
                        Dajaxice.companies.get_company_industries(Dajax.process, {'option':this.value});
                    }
                );
            });
        });
    </script>
{% endblock %}
